#include "stdafx.h"
#include <cmath>
#define PI 3.1415926
//#include
StdAfx::StdAfx()
{
}
int GetXiangXian(double dblCos, double dblSin)
{
        if(dblSin >= 0)
        {
                if(dblCos >= 0)
                        return 1;
                else
                        return 2;
        }else
        {
                if(dblCos >= 0)
                        return 4;
                else
                        return 3;
        }
}

double GetXiangJiao(double dblSin, double dblCos)
{
        double dblXiangJiao = 0;
     //   dblXiangJiao = std::atan2(dblCos,dblSin);
     //   if(dblXiangJiao < 0)
     //       dblXiangJiao +=PI * 2;
     //   dblXiangJiao *= 180 / PI;

        if (dblCos>0 && dblSin>0)
               dblXiangJiao=std::atan(dblCos/dblSin);
        else if (dblCos>0 && dblSin<0)
               dblXiangJiao=PI+std::atan(dblCos/dblSin);
        else if (dblCos<0 && dblSin<0)
               dblXiangJiao=PI+std::atan(dblCos/dblSin);
        else if (dblCos<0 && dblSin>0)
               dblXiangJiao=2*PI+std::atan(dblCos/dblSin);
        else if (dblSin==0)
        {
                if  (dblCos>0)
                     dblXiangJiao=0;
                if (dblCos<0)
                     dblXiangJiao=PI;
        }
        dblXiangJiao *= 180 / PI;


        return dblXiangJiao;

        /*int iXiangXian;
        if(dblCos == 0)
        {
                if(dblSin > 0)
                        return 90;
                else
                        return 270;
        }
        dblXiangJiao = System::Math::Atan(dblSin / dblCos) * 180 / System::Math::PI;
        iXiangXian = GetXiangXian(dblSin, dblCos);
        if(iXiangXian == 2 || iXiangXian == 3) dblXiangJiao = dblXiangJiao + 180;
        if(iXiangXian == 4) dblXiangJiao = dblXiangJiao + 360;
        return dblXiangJiao;*/
}

QString getNetDescription(QString sDescription)
{
        QString sValue = "Network adapter '" + sDescription + "' on local host";
        return sValue;
}

QString getHexFormat(int iValue)
{
        QString sRes;
     //   sRes = iValue.ToString("X");
        sRes=QString::number(iValue);
        if(iValue < 0x10)
                sRes = "0" + sRes;
        return sRes;
}
